
module SimpleDB where

import Maybe
import qualified Data.Map as Map

data DomainDB = DomainDB {
    domainMap :: Map.Map String Domain
}

data Domain = Domain {
    domainName :: String,
    itemMap :: Map.Map String Item
}

data Item = Item {
    itemName :: String,
    attrs :: Attributes
}

type Attributes = Map.Map String String

getAttrs :: DomainDB -> String -> String -> Attributes
getAttrs ddb domainKey itemKey =
    let
        domain = fromJust $ Map.lookup domainKey $ domainMap ddb
    in
        attrs $ fromJust $ Map.lookup itemKey $ itemMap domain

getAttr :: DomainDB -> String -> String -> String -> String
getAttr ddb domainKey itemKey attrKey =
    fromJust $ Map.lookup attrKey $ getAttrs ddb domainKey itemKey

{- TODO: implement query -}

